package resopnse_msg

import "github.com/gin-gonic/gin"

type Mess struct {
	//Name string
	Msg    string
	Status bool
	Code   int
	Data   interface{}
}
type Data struct {
	Total int
	Mess
}

//data success
func DataSuccess(c *gin.Context, httpCode int, data *Data) {
	c.JSON(httpCode, map[string]interface{}{
		"Data":   data.Data,
		"Msg":    data.Msg,
		"Code":   data.Code,
		"Status": data.Status,
		"Total":  data.Total,
	})
	return
}

//请求成功
func Success(c *gin.Context, httpCode int, code int, msg string, status bool, jsonStr interface{}) {
	c.JSON(httpCode, map[string]interface{}{
		"Data":   jsonStr,
		"Msg":    msg,
		"Code":   code,
		"Status": status,
		//合并 文件
	})
	return
}

// 返回失败
func Err(c *gin.Context, httpCode int, code int, msg string, jsonStr interface{}) {
	c.JSON(httpCode, map[string]interface{}{
		"Data":   jsonStr,
		"Msg":    msg,
		"Code":   code,
		"Status": false,
	})
	return
}


// msg 判断 out Msg
func ResponseMsg(types string) string{
	switch types {
	case "1":return  "热榜查询！"
	case "2":return  "话题榜查询！"
	default:
		return "查询错误"
	}
}